go to previous page   go to home page   hear noise   go to next page

Answer:

The very first letter in the program is wrong.


A Capital Mistake

The reserved word "class" has been changed to "Class" with a capital "C". So what? This is called a syntax error. A syntax error is a "grammatical error" in using the programming language. Here is what happens when the mistaken program is compiled:

The compiler tried to translate the source code into bytecode but got confused when it got to a capital "C" it did not expect. The error message is not very clear. They never are. But at least it shows where the compiler got confused. The compiler did not create a new bytecode file because it stopped translating when it got to the error.


C:\Temp>javac Hello.java

  compiling: Hello.java
Hello.java:1: Class or interface declaration expected.
Class Hello
^
1 error

QUESTION 8:

What is the error in the following program?

class hello
{
  public static void main ( string[] args )
  {
    System.out.println("hello world!");
  }
}

Click for a hint.